CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/share/accounts/[account_id].tsx
Views: 687
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
/*
7
Page for a given user.
8
*/
9
10
/*
11
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
12
* License: MS-RSL – see LICENSE.md for details
13
*/
14
15
import { join } from "path";
16
import basePath from "lib/base-path";
17
import getAccountInfo from "lib/share/get-account-info";
18
import withCustomize from "lib/with-customize";
19
import Account from "components/account/account";
20
21
export default Account;
22
23
export async function getServerSideProps(context) {
24
const { account_id } = context.params;
25
try {
26
const accountInfo = await getAccountInfo(account_id, context.req);
27
if (accountInfo.name) {
28
// This account has a nice username. Redirect to that instead
29
// of rendering here.
30
return { props: { redirect: join(basePath, accountInfo.name) } };
31
}
32
return await withCustomize({
33
context,
34
props: accountInfo,
35
});
36
} catch (_err) {
37
// console.log(err);
38
return { notFound: true };
39
}
40
}
41
42